{extend name="public/base"}

{block name="title"}就行天下-编辑收货地址{/block}

{block name="style"}
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main.css?v=1.0?v=1.0" />
<link rel="stylesheet" href="__STATIC__/home/css/set.css" />
{css href="__STATIC__/home/css/map.css"}
<style>
    .select_area {
        position: fixed;
        top: .5rem;
        left: 1rem;
        padding: 0 .7rem;
        background: #36a110;
        color: #fff;
        border-radius: 5px;
        z-index: 10000;
    }
</style>
{/block}

{block name="main"}
<div class="pageControl twoCodeMain">
    <form>
        <div class="main-top"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">增添收货地址</h1>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                <span>收货人</span>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" placeholder="请输入收货人的姓名" name="linkman" value="{$data.linkman|default=''}">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                <span>手机号</span>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input"  type="number" placeholder="手机号" name="mobile" value="{$data.mobile|default=''}">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                <span>详细地址</span>
            </div>
            <div class="weui-cell__bd">
                <!--<p class="activity_address">正在获取地址...</p>-->
                <input type="text" class="weui-input" placeholder="请输入活动的详细地址" name="address" value="{$data.address|default=''}">
                <!--<input type="hidden" name="lat" value="{$data.lat|default=''}" data-error="请选择活动详细地址"/>-->
                <!--<input type="hidden" name="lng" value="{$data.lng|default=''}" data-error="请选择活动详细地址"/>-->
            </div>
            <div class="weui-cell__ft"></div>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                <span>邮政编码</span>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="number" placeholder="邮政编码" name="postcode" value="{$data.postcode|default=''}">
            </div>
        </div>
        <div class="weui-cell ">
            <div class="weui-label" style="width: 4.6rem;">
                <span>设为默认地址</span>
            </div>
            <div class="weui-cell__bd">

            </div>
            <div class="weui-cell__ft">
                <label for="switchCP" class="weui-switch-cp">
                    <input id="switchCP" class="weui-switch-cp__input" type="checkbox" checked="checked" name="is_default" value="1">
                    <div class="weui-switch-cp__box"></div>
                </label>
            </div>
        </div>
        <input type="hidden" name="id" value="{$data.id|default='0'}">
        <div class="p05">
            <a href="javascript:;" class="weui-btn cl-f fs065 mtop05 bg-c40 save_address">
                    保 存
            </a>
        </div>
    </form>
</div>
{/block}

{block name="javascript"}
<script>
    $(function () {
        $(".save_address").click(function () {
            $.ajax({
                type : 'POST',
                url : '{:url("save_address")}',
                data : $('form').serialize(),
                dataType : 'json',
                success : function (msg) {
                    if (msg.code == 200) {
                        $.toptip('保存成功！', 'success');
                        window.location.href = '{:url("index")}';
                    } else {
                        $.toptip(msg.msg);
                    }
                    console.log(msg);
                }
            });
        });
    });
</script>
{/block}